<?php
class View_Administration_Project_Servers extends View_Administration_Project
{
	public function buildContent( $projectId )
	{
		$request	= CMF_Krypton_Core_Registry::getStatic( 'request' );
		$session	= CMF_Krypton_Core_Registry::getStatic( 'session' );
		$words		= $this->words['project']['assignServers'];

		$servers	= Logic_Server::getServers( true );
		$relations	= Logic_Project::getServersFromProject( $projectId, false );
		$add	= $remove	= array();
		foreach( $servers as $serverId => $serverTitle )
		{

			if( in_array( $serverId, $relations ) )
				$remove[$serverId]	= $serverTitle;
			else
				$add[$serverId]	= $serverTitle;
		}
		$sources	= array(
			'opt_add_servers'		=> $add,
			'opt_remove_servers'	=> $remove,
		);

		//  --  UI COMPONENTS  --  //
		$ui	= array(
			'words'		=> $words,
			'form'		=> $this->buildForm(
				'administration/project',
				'assignServers',
				'project',
				'assignServers',
				array(),
				$sources
			),
			'buttonAdd'		=> $this->html->Button(
				'addServers',
				$words['buttonAdd'],
				'but add'
			),
			'buttonRemove'	=> $this->html->Button(
				'removeServers',
				$words['buttonRemove'],
				'but remove'
			),

			'form.tag'		=> $this->html->Form(
				'assignServers',
				self::getUrl( array( 'projectId' => $projectId ) )
			),
			'caption'	=> $this->html->TableCaption( $words['caption'], 'edit' ),
			'colgroup'	=> $this->html->ColumnGroup( $words['colgroup'] ),
		);
		return $this->loadTemplate( 'administration.project.servers', $ui );
	}
}
?>